import requestProxy from '@/utils/request';

const { request } = requestProxy;

// 删除文件
export function deleteFile(id) {
  return request({
    url: `/admin/brand/file/${id}`,
    method: 'delete'
  });
}

// 导入表格文件
export function uploadFile(fileData) {
  return request({
    url: '/admin/brand/file/import',
    method: 'post',
    data: {
      fileData
    }
  });
}

// 导入账号列表
export function importAccount(fileData) {
  return request({
    url: '/admin/brand/account/import',
    method: 'post',
    data: {
      fileData
    }
  });
}

// 获取账号列表
export function getAccountList(params) {
  return request({
    url: '/admin/brand/resource/list',
    method: 'get',
    params
  });
}

// 获取文件列表
export function getFileList(page, perPage, params) {
  return request({
    url: '/admin/brand/file/list',
    method: 'get',
    params: {
      page,
      perPage,
      title: params.title,
      time: params.time
    }
  });
}

// 获取指定文件指定tab文件
export function getFileData(id, params, cancelToken) {
  return request({
    url: `/admin/brand/file/${id}/data`,
    method: 'get',
    params,
    cancelToken
  });
}

// 获取文件tab列表
export function getFileTabs(id) {
  return request({
    url: `/admin/brand/file/${id}/tabs`,
    method: 'get'
  });
}

// 获取指定文件指定tab文件列表表头的筛选值
export function getFileTitleList(id, tabId, cancelToken) {
  return request({
    url: `/admin/brand/file/${id}/titles/data`,
    method: 'get',
    params: {
      tabId
    },
    cancelToken
  });
}

// 数据列表导出
export function getFileDataExport(id) {
  return request({
    url: `/admin/brand/file/${id}/data/export`,
    method: 'get'
  });
}

// 员工列表
export function getList(page, perPage, params) {
  return request({
    url: '/admin/brand/user/list',
    method: 'get',
    params: {
      page,
      perPage,
      content: params.content
    }
  });
}

// 获取账户信息
export function getUserInfo(id) {
  return request({
    url: `/admin/brand/user/info/${id}`,
    method: 'get'
  });
}

// 编辑账户信息
export function infoEdit(id, data) {
  return request({
    url: `/admin/brand/user/${id}/edit`,
    method: 'put',
    data
  });
}

// 获取权限信息
export function getRole(id) {
  return request({
    url: `/admin/brand/user/role/${id}`,
    method: 'get'
  });
}

// 编辑权限信息
export function roleEdit(id, data) {
  return request({
    url: `/admin/brand/user/role/${id}/edit`,
    method: 'put',
    data
  });
}

// 获取矩阵列表
export function getMatrix() {
  return request({
    url: '/admin/brand/matrix/list',
    method: 'get'
  });
}

// 获取账号列表
export function getAccout() {
  return request({
    url: '/admin/brand/account/list',
    method: 'get'
  });
}

// 获取子部门列表
export function getSubDept(id) {
  return request({
    url: `/admin/brand/subDept/list/${id}`,
    method: 'get'
  });
}
